import Vue from 'vue';
import Vuex from 'vuex';
import * as getters from './getters';
import * as actions from './actions';
import * as mutations from './mutations';
import profile from './modules/profile';
import forward from './modules/forward';
import infoEntry from './modules/infoEntry';
import buyTicket from './modules/buyTicket';


Vue.use(Vuex);

const state = {
  count: 0,
  personal: {
    // psnid: '9'
  }, //登录成功以后的个人信息
  loading: false //加载loading(是否显示)加载loading
};

const store = new Vuex.Store({
  state,
  getters,
  actions,
  mutations,
  modules: {
    profile, //  个人中心
    infoEntry, //  K部分用票人信息
    buyTicket,  //购票部分
    forward,
  }
});

if (module.hot) {
  module.hot.accept([
    './getters',
    './actions',
    './mutations',
    './modules/profile',
    './modules/forward',
    './modules/infoEntry',
  ], () => {
    store.hotUpdate({
      getters: require('./getters').default,
      actions: require('./actions').default,
      mutations: require('./mutations').default,
      modules: {
        profile: require('./modules/profile').default,
        forward: require('./modules/forward').default,
        infoEntry: require('./modules/infoEntry').default,
      }
    });
  });
}

export default store;
